package DomainLayer;
import java.util.ArrayList;


public class OrderCollection
{
    private ArrayList<Order> orders;
    private static OrderCollection instance; 
    
    private OrderCollection()
    {
        orders=new ArrayList<Order>();
    }
    
    //@return only one object if class OrderCollection.
    public static OrderCollection getInstance()
    {
        if (instance== null)
        {
            instance = new OrderCollection();
        }
        return instance;
    }

    public void addOrder(Order order)
    {
        orders.add(order);
    }  
    
    //@return order according its id.
    public Order findOrder(int id)
    {
        for(Order order: orders)
        {
            if (order.getID()==id)
            {
                return order;
            }
        }
            return null;
    }
    
    public void deleteOrder(int id)
    {
        orders.remove(findOrder(id));
    }
}